﻿if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].GetCmdTypeOrder') and OBJECTPROPERTY(id, N'IsScalarFunction') = 1)
DROP FUNCTION [dbo].GetCmdTypeOrder

GO

CREATE FUNCTION dbo.GetCmdTypeOrder
(
	@cmdType varchar(10)
)
RETURNS bit
AS
BEGIN
	IF @cmdType = 'INSERT' RETURN 0
	IF @cmdType = 'DELETE' RETURN 2
	RETURN 1
END